﻿#include"game.h"
void menu()
{
	printf("*******************************\n");
	printf("***********  1. play  *********\n");
	printf("*******************************\n");
	printf("************ 0. exit  *********\n");
	printf("*******************************\n");
	printf("*******************************\n");

}
void test(char board[ROW][COL],int row,int col)
{
	int input = 0;
	srand((unsigned int)time(NULL));
	do
	{
		menu();
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			InitBoard(board, ROW, COL);
			DisplayBoard(board, ROW, COL);
			while (1)
			{
				char ret = 0;
				Player_Move(board, ROW, COL);
				DisplayBoard(board, ROW, COL);
				ret = is_win(board, ROW, COL);
				if (ret == 'X')
				{
					printf("您打败了电脑！\n");
					break;
				}
				Computer_Move(board, ROW, COL);
				DisplayBoard(board, ROW, COL);
				ret = is_win(board, ROW, COL);
				if (ret == 'O')
				{
					printf("您被人工智障打败了！\n");
					break;
				}
				if (is_full(board, ROW, COL) == 'Y')
				{
					printf("您和电脑不分上下\n");
				}
				else if (is_full(board, ROW, COL) == 'N')
					;
			}
				break;
			case 0:
				break;
			default:
				printf("请输入有效选择\n");
				break;
		}
	} while (input);
}
int main()
{
	test(board, ROW, COL);
}
